<%-- 
    Document   : question-all
    Created on : Feb 11, 2012, 9:20:54 AM
    Author     : PhucAn
--%>


<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include  file="../handler/question-manage-action.jsp" %>

<html>
    <head>       
        <title>Question management</title>
        <script type="text/javascript">
            function submit(idx){
                document.getElementById("selected-item-id").value=idx;
                document.forms[0].submit();
            }
            
            function addToExam(idx){
                $.ajax({
                    type:"post",
                    url:"../handler/question-manage-addto-exam.jsp",
                    data:"id="+idx,
                    success:function(msg){
                        alert(msg);
                    }
                });
            }
        </script>
    </head>
    <body>
        <h1>Question management</h1>
        <form action="#" method="post">
            <div>
                <input type="text" name="search" id="search" value="${search}"/>
                <input type="submit" name="do-search" value="Search"/>
            </div>
            <table class="data-table">
                <tr>
                    <th>Content</th>
                    <th>Level</th>
                    <th>Category</th>
                </tr>
                <c:forEach var="q" items="${list}">
                <tr>
                    <td>${q.content}</td>
                    <td>${q.level}</td>
                    <td>${q.category.id}</td>
                    <td>
                        <a href="?pcontent=modify-question&id=${q.id}&cateid=${q.category.id}">Edit</a>
                        - 
                        <a  href="javascript:submit(${q.id});">Delete</a> 
                        - 
                        <a href="javascript:addToExam(${q.id});">Add to exam</a>
                    </td>
                </tr>
                </c:forEach>                
            </table>
            <input type="hidden" id="selected-item-id" name="selected-item-id"/>
            <div id="paging-bar">${pagingNav}</div>
        </form>
    
    </body>
</html>
